from selenium.webdriver.support.wait import WebDriverWait


class BaseAction(object):

    def __init__(self, driver):
        self.driver = driver

    def find_element(self, feature, time=10, poll=0.1):
        return WebDriverWait(self.driver, time, poll).until(lambda x: x.find_element(*feature))

    def send_keys(self, feature, text, time=10, poll=0.1):
        self.find_element(feature, time, poll).send_keys(text)

    def click(self, feature, time=10, poll=0.1):
        self.find_element(feature, time, poll).click()

    def get_text(self, feature, time=10, poll=0.1):
        return self.find_element(feature, time, poll).text
